import React from 'react';
import { Button, Row, Col, Modal, message} from 'antd';
import { inject, observer } from 'mobx-react';
import {routerShape} from 'react-router';
import { WeaTab, WeaTop, WeaSteps, WeaNewScroll, WeaRichText, WeaDialog, WeaTextarea, WeaBrowser, WeaRightMenu, WeaTools, WeaReqTop, WeaAlertPage  } from 'ecCom';
import { toJS } from "mobx";
import { imgZoom} from '../../util/index';
import { WeaLocaleProvider } from 'ecCom';
const getLabel = WeaLocaleProvider.getLabel;
const confirm = Modal.confirm;
import "./index.less";
import TaskView from './TaskView';
import ProjectSub from '../single/project/ProjectSub';
import StageSetList from '../single/project/StageSetList';
import ResourcePage from '../single/project/ResourcePage';
import ProjectStastics from '../single/project/ProjectStastics';
import Ovreview from './cardContent/overview.js';
import PrjSelect from './prjSelect/prjSelect.js';
import PrjForm from "../prjForm.js";
import Edit from "./edit";
import { Count } from "./cardContent/count";
import { Header } from "./cardContent/header";
import { JlChild, jlParamsHandle, Daily, Log } from "../tools/dtConfig";
import Report from "../prjReport";
import ProjectDialog from '../dialog/projectDialog'
import SaveTemplateDialog from "../dialog/SaveTemplateDialog"
import ProjectShare from '../common/sharePage'

@inject("projectCardStore", "taskCardNewStore")
@observer
class ProjectCard extends React.Component {
    static contextTypes = {
        router: routerShape
    }
    static defaultProps = {
        prefixCls: 'prj-portal'
    };
    constructor(props) {
        super(props);
        this.state = {
            selectedKey: "1",
            value: "3",
            viewAttr: 3,
            selectedDynamicTab: 0,
            showDailyDiv: false,
            showExDiv: false,
            showReply: {},
            showDailyEdit: {},
            visible: false,
            showRich: false,
            richValue: '',
            richValueChangeMethod: () =>{},
            richMethod: () =>{},
            isCreate:true,
            workPlanVisible:false
        };
    }

    componentDidMount() {
        let dom = ReactDOM.findDOMNode(this);
		imgZoom(dom, ".wea-cl-content");
        const {projectCardStore,location,prjid} = this.props;
        const {prjCardStore} = projectCardStore;
        // const {prjid} = location.query;
        if(prjid==''||prjid==null){
            projectCardStore.setPrjid(location.query.prjid);
            prjCardStore.getPrjTabs({prjid : location.query.prjid});
        }else{
            projectCardStore.setPrjid(prjid);
            prjCardStore.getPrjTabs({prjid : prjid});
        }
        if (!window.weaWorkplan) {
            // 异步加载别模块的静态资源
            eventRegister.loadModule('f_workplan', () => {
                prjCardStore.setLoaded(true)
            }, () => {
                // 加载文件失败 的业务处理， 网络超时，没文件之类
            })
        } else {
            prjCardStore.setLoaded(true)
        }
    }

    componentWillReceiveProps(nextProps, nextState) {
        const {prjid}= this.props;
        if(prjid==''||prjid==null){
            const { selectedKey } = this.state;
            const { projectCardStore, location } = nextProps;
            const { topTab, prjCardStore, getRightMenu, getPortalProjectInfo, setPrjidFun } = projectCardStore;
            const {prjid} = location.query;
            const tabDatas1 = toJS(topTab);
            if (tabDatas1) {
                for (let i = 0; i < tabDatas1.length; i++) {
                    if(tabDatas1[i].shortname == "prjinfo" && tabDatas1[i].key == selectedKey) {//项目卡片
                        this.setState({ selectedDynamicTab: 0, showDailyDiv: false, showExDiv: false, showReply: {}, showRich: false });
                        let dom = ReactDOM.findDOMNode(this);
                        imgZoom(dom, ".wea-cl-content");
                        projectCardStore.setPrjid(prjid);
                        if (!window.weaWorkplan) {
                            // 异步加载别模块的静态资源
                            eventRegister.loadModule('f_workplan', () => {
                                prjCardStore.setLoaded(true)
                            }, () => {
                                // 加载文件失败 的业务处理， 网络超时，没文件之类
                            })
                        } else {
                            prjCardStore.setLoaded(true)
                        }
                    }else if (tabDatas1[i].shortname == "prjshare" && tabDatas1[i].key == selectedKey) {//项目共享
                        prjCardStore.prjid = prjid;
                        prjCardStore.getPrjShareList();
                        getRightMenu({'type':'prjshare'});
                    }else if(tabDatas1[i].shortname == "tasklist" && tabDatas1[i].key == selectedKey){//任务列表
                        getRightMenu({'type':'taskview'});
                    }else if(tabDatas1[i].id == selectedKey && tabDatas1[i].shortname == "gantt") {  //甘特图
                        setPrjidFun(prjid);
                        getPortalProjectInfo();
                    }
                }
            }
        }else{
            const { selectedKey } = this.state;
            const { projectCardStore, prjid } = nextProps;
            const { topTab, prjCardStore, getRightMenu, setPrjidFun, getPortalProjectInfo } = projectCardStore;
            const tabDatas1 = toJS(topTab);
            if (tabDatas1) {
                for (let i = 0; i < tabDatas1.length; i++) {
                    if(tabDatas1[i].shortname == "prjinfo" && tabDatas1[i].key == selectedKey) {//项目卡片
                        this.setState({ selectedDynamicTab: 0, showDailyDiv: false, showExDiv: false, showReply: {}, showRich: false });
                        let dom = ReactDOM.findDOMNode(this);
                        imgZoom(dom, ".wea-cl-content");
                        projectCardStore.setPrjid(prjid);
                        if (!window.weaWorkplan) {
                            // 异步加载别模块的静态资源
                            eventRegister.loadModule('f_workplan', () => {
                                prjCardStore.setLoaded(true)
                            }, () => {
                                // 加载文件失败 的业务处理， 网络超时，没文件之类
                            })
                        } else {
                            prjCardStore.setLoaded(true)
                        }
                    }else if (tabDatas1[i].shortname == "prjshare" && tabDatas1[i].key == selectedKey) {//项目共享
                        prjCardStore.prjid = prjid;
                        prjCardStore.getPrjShareList();
                        getRightMenu({'type':'prjshare'});
                    }else if(tabDatas1[i].shortname == "tasklist" && tabDatas1[i].key == selectedKey){//任务列表
                        setPrjidFun(prjid);
                        getRightMenu({'type':'taskview'});
                    }else if(tabDatas1[i].id == selectedKey && tabDatas1[i].shortname == "gantt") {  //甘特图
                        setPrjidFun(prjid);
                        getPortalProjectInfo();
                    }
                }
            }
        }
    }

    componentDidUpdate(prevProps, prevState) {
        let dom = ReactDOM.findDOMNode(this);
        imgZoom(dom, ".wea-cl-content");
    }
    initPage = (v) => {
        const { selectedKey } = this.state;
        if (selectedKey === "1") { this.props.projectCardStore.setPrjid(v); }
    }
    render() {
        const { prefixCls, projectCardStore, location, fromPortal, changeCallBack = () =>{}, dellCallBack } = this.props;
        let prjid = this.props.prjid;
        if(prjid==''||prjid==null){
            prjid = location.query.prjid;
        }
        const { baseInfo, projectInfo:{fieldinfo}, loading, exchangeList, submitDaily, apiErr, canSubmitDaily, statistics: { rwzs }, projectInfo:{prjname}, projectInfoStore, getPortalProjectInfo, topTab, prjCardStore, getPortalProjectDynamicInfo } = projectCardStore;
        const { selectedDynamicTab, visible, showRich, richValue, selectedKey } = this.state;
        const { manager, managericons, planbegindate, planenddate, stages, members, creatername, createdate } = baseInfo;
        const overviewProp = { loading, manager, managericons, stages, planbegindate, planenddate };
        const account = WeaTools.ls.getJSONObj('theme-account');
        const checkOptions = [
            {
                title: getLabel('332','全部'),
                index: 0
            }, {
                title: getLabel('20620','日报'),
                index: 1
            }, {
                title: getLabel('518347','交流'),
                index: 2
            }, {
                title: getLabel('83','日志'),
                index: 3
            }
        ];
        const Elem = (
            <div className='prj-dynamic-tab'>
                {checkOptions.map((opt, index) => (<div className='prj-dynamic-tab-item' onClick={() => { this.changeDynamicTab(index);this.setState({richValue:''}); }}><span key={index} className={(index == selectedDynamicTab) ? "active" : ""}>{opt.title}</span></div>))}
            </div>
        );
        const height = document.body.offsetHeight - $(".prj-portal-page .wea-new-top-wapper").height() - 56 - 225;
        let scrollHeight = ($(".e9theme-layout-header").length > 0 || $(".e8theme-layout-header").length > 0) ? height - 55 - 20 : height - 20;
        if(fromPortal){
            scrollHeight = scrollHeight - 51;
        }
        const richSubmitfun = selectedDynamicTab == 1 ? submitDaily : this.dosubmit;
        const richid = {
            "1": "create_daily",
            "2": "create_discuss"
        }[selectedDynamicTab.toString()]
        let richPlaceholder = {
            "1": getLabel('518257','填写日报'),
            "2": getLabel('518258','填写相关交流')
        }[selectedDynamicTab.toString()];
        const canSubmit = {
            "1": canSubmitDaily,
            "2": true
        }[selectedDynamicTab.toString()];
        if(!canSubmit){
            richPlaceholder += '('+getLabel('520676','一天只能提交一次') +')';
        }
        const richProps = {
            transfStr: this.transfStr,
            richChange: this.richChange,
            richSubmitfun: richSubmitfun,
            showRichfun: this.showRichfun,
            showDialogfun: this.showDialogfun,
            setIsCreate: (bool) =>{this.setState({isCreate:bool})},
            exchangeList,
            richid,
            showRich,
            richPlaceholder,
            loading,
            canSubmit
        }
        const richDom = (hasEdit = true) => (<Row ecId={`${this && this.props && this.props.ecId || ''}_Row@vabity`}>
            <div className='dongtai-wraps' style={{ backgroundColor: '#ffffff', marginBottom: '10px', padding: "5px 20px" }}>
                {hasEdit && <Edit ecId={`${this && this.props && this.props.ecId || ''}_Edit@nxmtt7`} {...richProps} />}
                {this.getDynamicContent()}
            </div>
        </Row>);
        if (apiErr === true) {
            return (
                Modal.warning({
                    title: getLabel('518351','发生错误'),
                    content: getLabel('504523','请联系管理员'),
                    onOk() { window.location.reload() }
                })
            )
        }

        const tabDatas1 = toJS(topTab);
        const that = this;
        let tabUrl = function (key) {
            if (tabDatas1) {
                for (let i = 0; i < tabDatas1.length; i++) {
                    if (tabDatas1[i].id == key && tabDatas1[i].shortname == "prjinfo") {   //基本信息
                        return <React.Fragment ecId={`${this && this.props && this.props.ecId || ''}_Fragment@tnmll7`}>
                        <div className={`${prefixCls}-card-wrapper ${prefixCls}-card-wrapper-top`}>
                            <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@k2e2ij`}
                                // className={`${prefixCls}-card-title`}
                                title={
                                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@ricjeg`} span="20">
                                        <span className={`${prefixCls}-main-card-title`}>{prjname}</span>&nbsp;
                                        <span className={`${prefixCls}-main-card-subTitle`}>（{creatername}&nbsp;{getLabel('127511','创建于') }&nbsp;{createdate}）</span>
                                    </Col>
                                }
                                buttons={that.getButtons()}
                                showDropIcon={true}
                                dropMenuDatas={that.getRightMenu()}
                                onDropMenuClick={that.onRightMenuClick.bind(that)}
                            />
                            {/* <Header /> */}
                            <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@jqeejm`} style={{ backgroundColor: "#f5f5f5" }} >
                                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@bbu38w`} md={16} lg={17}>
                                    <div className={`${prefixCls}-leftT-container`}>
                                        <div style={{ width: "60%" }}>
                                            <Ovreview ecId={`${this && this.props && this.props.ecId || ''}_Ovreview@99hvin`} overviewProp={overviewProp} />
                                        </div>
                                        <div className={`${prefixCls}-shu-border`}></div>
                                        <div style={{ width: "40%", padding: "20px" }}>
                                            <Count ecId={`${this && this.props && this.props.ecId || ''}_Count@7lp5xg`} />
                                        </div>
                                    </div>
                                    <div className={`${prefixCls}-leftB-container`} >
                                        <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@f04w85`} height={scrollHeight} >
                                            <PrjForm ecId={`${this && this.props && this.props.ecId || ''}_PrjForm@lbzsbk`} height={scrollHeight} fieldinfo={fieldinfo} hasTopTitle={true}/>
                                        </WeaNewScroll>
                                    </div>
                                </Col>
                                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@1fsxhx`} md={8} lg={7}>
                                    <div className={`${prefixCls}-right-container`} style={{ backgroundColor: "#fff", height: "100%" }}>
                                        <div className={`${prefixCls}-dt-title`}>
                                            <span className={`${prefixCls}-main-card-title`}>{getLabel('518262','项目动态')}</span>&nbsp;
                                                </div>
                                        {Elem}
                                        <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@58yi93`} height={scrollHeight - 50 - 30 + 225} className={`${prefixCls}-content-container`}>
                                            {
                                                {
                                                    '0': richDom(false),
                                                    '1': richDom(),
                                                    "2": richDom(),
                                                    '3': richDom(false)
                                                }[selectedDynamicTab.toString()]
                                            }
                                        </WeaNewScroll>
                                    </div>
                                </Col>
                            </Row>
                        </div>
                        <ProjectDialog ecId={`${this && this.props && this.props.ecId || ''}_ProjectDialog@kazq03`} contentStore={projectInfoStore} callBack={() =>{
                            if(fromPortal){
                                changeCallBack&&changeCallBack();
                            }
                            getPortalProjectInfo();
                            if(selectedDynamicTab==0){
                                getPortalProjectDynamicInfo("all");
                            }else if(selectedDynamicTab==3){
                                getPortalProjectDynamicInfo("log");
                            }
                        }}
                        dellCallBack={that.dellCallBack}
                        from={'portal'}
                        />
                        <SaveTemplateDialog ecId={`${this && this.props && this.props.ecId || ''}_SaveTemplateDialog@c796wt`} prjCardStore={projectInfoStore}/>

                        {
                            prjCardStore.isreload && window.weaWorkplan && window.weaWorkplan.com && window.weaWorkplan.com.WorkPlanCreate &&
                            (<window.weaWorkplan.com.WorkPlanCreate ecId={`${this && this.props && this.props.ecId || ''}_WorkPlanCreate@7kcd4m`}
                                type={"create"}//新建为'create',查看为'preview',编辑edit,共享share
                                visible={that.state.workPlanVisible}//显隐受控
                                doClose={() => { that.setWorkPlanVisible(false); }}//关闭回调
                                onlyClose={() => { that.setWorkPlanVisible(false) }}//关闭回调,只做关闭操作
                                workPlanId={""} //日程id，1查看日程时用到
                                createConditionParams={[]}//创建的默认值日期和时间,没有传[]
                                activeKey={""} //查看页面显示的面板1是基本信息，7是相关交流
                                //{(key) => { }}//查看页面切换面板的回调
                                selectUser={account && account.userid}//新建日程的创建人id
                                workPlanTypeOptions={"2"}//客户模块的新建日程，普通新建传'',客户新建传3
                                crmIDs={[]}//通过客户模块新建日程，并自动带出相关客户,[{'id':'','name':''}]
                                projectid={prjid}
                                description={""}//客户模块需求，支持新建时传入的'基本信息-内容'
                            />)
                        }

                    </React.Fragment>
                    } else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "tasklist") {//任务列表
                        return <TaskView ecId={`${this && this.props && this.props.ecId || ''}_TaskView@0jdaft`} key={prjid} prjid={prjid} fromPortal={fromPortal} changeCallBack={() =>{changeCallBack();}}/>
                    } else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "childprj") { //子项目
                        return <ProjectSub ecId={`${this && this.props && this.props.ecId || ''}_ProjectSub@zyco59`} key={prjid} prjid={prjid} fromPortal={fromPortal}/>
                    }  else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "prjshare") {  //共享设置
                        return  <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@3bb6dm`} datas={that.getRightMenu()} onClick={that.onRightMenuClick.bind(that)}>
                                <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@rsu3ds`}
                                    buttons={that.getButtons()}
                                    showDropIcon={true}
                                    dropMenuDatas={that.getRightMenu()}
                                    onDropMenuClick={that.onRightMenuClick.bind(that)}
                                />
                                <ProjectShare ecId={`${this && this.props && this.props.ecId || ''}_ProjectShare@w3r7yl`} key={prjid} prjid={prjid} fromPortal={fromPortal} contentStore={prjCardStore} title={getLabel(83816, "添加项目共享")} />
                            </WeaRightMenu>
                    } else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "stareport") {  //统计报告
                        return <ProjectStastics ecId={`${this && this.props && this.props.ecId || ''}_ProjectStastics@7tt2b5`} key={prjid} prjid={prjid} fromPortal={fromPortal}/>
                    } else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "gantt") {  //甘特图
                        return tabDatas1[i].linkurl; //"/proj/gantt/gantt.jsp?projectid=8&ProjID=8";
                    } else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "stageset") {  //阶段设置
                        return <StageSetList ecId={`${this && this.props && this.props.ecId || ''}_StageSetList@m1v0d4`} key={prjid} prjid={prjid} fromPortal={fromPortal}/>
                    } else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "resources") {  //相关资源
                        return <ResourcePage ecId={`${this && this.props && this.props.ecId || ''}_ResourcePage@8dg29c`} key={prjid} prjid={prjid} fromPortal={fromPortal}/>
                    } else if (tabDatas1[i].id == key && tabDatas1[i].shortname == "") {
                        if(tabDatas1[i].linkurl.indexOf("/main/prj/prjReport") > -1){
                            return <Report ecId={`${this && this.props && this.props.ecId || ''}_Report@mbceo1`} key={prjid} prjid={prjid} />;
                        }else if (tabDatas1[i].linkurl.indexOf("noright") > -1) {
                            return <WeaAlertPage ecId={`${this && this.props && this.props.ecId || ''}_WeaAlertPage@kzdc08`} >
                                <div style={{ color: '#000' }}>
                                    {getLabel(2012, "对不起，您暂时没有权限！")}
                                </div>
                            </WeaAlertPage>
                        } else {
                            return tabDatas1[i].linkurl;
                        }
                    }
                }
                return ""
            }
        }(selectedKey);

        const editHeight = window.screen.width>=1920?"600px":"400px";

        return (
            <div className="prj-portal-page">
                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@7dmtqj`}>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@u8nkdk`} span='10'>
                        <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@ualn0w`}
                            title={
                                fromPortal?'':
                                <PrjSelect ecId={`${this && this.props && this.props.ecId || ''}_PrjSelect@woaf7u`} value={prjid} title={prjname} onChange={v =>{
                                    this.forwardProjectCard(v);
                                }} />
                            }
                            icon={fromPortal?'':<i className='icon-coms-project' />}
                            iconBgcolor={fromPortal?'':'#217346'}
                        />
                    </Col>
                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@c9vgnf`} span='14' style={{
                        backgroundColor: '#f9f9f9',
                        borderBottom: '1px solid #eaeaea',
                        height: '51px'
                    }}>
                        <WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@r2si9j`}
                            style={{float:'right',maxWidth:'100%'}}
                            datas={topTab}
                            keyParam="viewcondition" //主键
                            selectedKey={this.state.selectedKey}
                            onChange={v => {this.changeTab(v);}}
                        />
                    </Col>
                </Row>
                <div className="prj-portal-content" style={{background:'#ffffff',height:fromPortal?'100%':'94%'}}>
                    {
                        typeof tabUrl === "object" ? <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@1scq1d`} scrollId='prj-req-content-main-scroll' height={fromPortal?'88%':'100%'}>
                        {
                            tabUrl 
                        }
                    </WeaNewScroll> :
                                <iframe src={tabUrl} id="prjtabiframe" name="prjtabiframe" className="flowFrame" frameborder="0" width="100%" height="100%" /> 
                    }
                </div>
                <WeaDialog ecId={`${this && this.props && this.props.ecId || ''}_WeaDialog@tint1h`}
                    title={getLabel(433,"描述")}
                    icon='icon-coms-project'
                    iconBgcolor='#217346'
                    visible={visible}
                    buttons={[
                        <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@t520fv@submit`} type="primary" onClick={() => { this.getRichSubmitfun('create'); this.showDialogfun(false) }}>{getLabel(383336, "提交")}</Button>,
                        <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@02qxsf@cancel`} type="ghost" onClick={() => this.setState({ visible: false })}>{getLabel(201,"取消")}</Button>
                    ]}
                    onCancel={() => this.setState({ visible: false })}
                    style={{ width: 'calc(100% - 200px)', height: editHeight }}
                >
                    <Edit ecId={`${this && this.props && this.props.ecId || ''}_Edit@gd8lus`} transfStr={this.transfStr} richChange={this.richChange} richid={richid} value={richValue} visibleDialog={true} exchangeList={exchangeList} loading={loading} />,
                </WeaDialog>
            </div>
        )
    }
    showDialogfun = (visible) => {
        this.setState({ visible })
    }


    getTopButtons = () => {
        const { projectCardStore: { topTab, prjid, prjCardStore } } = this.props;
        let buttons = [];
        buttons.push(<WeaTab ecId={`${this && this.props && this.props.ecId || ''}_WeaTab@hpayry`}
            datas={topTab}
            keyParam="viewcondition" //主键
            selectedKey={this.state.selectedKey}
            onChange={v => {this.changeTab(v);}}
        />);
        return buttons
    }

    huifuHandle = (item,type) => {
        let { showReply } = this.state;
        let showReply1 = showReply;
        showReply1[item.id] = !showReply1[item.id];
        this.setState({ showReply: showReply1 });
    }

    shanchuHandle = () => {
    }

    bianjiHandle = (item,tabKey) => {
        let { showDailyEdit } = this.state;
        let showDailyEdit1 = showDailyEdit;
        showDailyEdit1[item.id] = !showDailyEdit1[item.id];
        this.setState({richValue:item.content});
        this.setState({ showDailyEdit: showDailyEdit1 });
        this.setState({richMethod:(v) =>{this.editDaily(item.id,tabKey);}});
        this.setState({richValueChangeMethod:(text) =>{this.setState({richValue:text});}});
        this.setState({isCreate:false});
    }

    tijiaoHandle = (showReply, submitType) => {
        const { saveReply } = this.props.projectCardStore;
        saveReply(item.id, submitType);
        let showReply1 = showReply;
        showReply1[item.id] = !showReply1[item.id];
        this.setState({ showReply: showReply1 });
    }

    getDynamicContent = () => {
        let datas = [];
        let { selectedDynamicTab, showReply, showDailyEdit } = this.state;
        const { exchangeList, logList, _BrowserList, prjid, dailys, setReply, saveReply, alldatas } = this.props.projectCardStore;
        let _exchangeList = toJS(exchangeList);
        if (selectedDynamicTab == 0) {
            alldatas.datas && alldatas.datas.map((item, index) => {
                const { type } = item;
                if (type == 1) {
                    datas.push(
                        <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@flwua7@${index}`} style={{ borderBottom: '1px solid #E2E2E2', marginTop: '20px' }}>
                            <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@h9g5ws@${index}`} span="3">
                                <img src={item.creater.imgurl} className="manager-img" style={{ marginLeft: "0px" }} />
                            </Col>
                            <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@20fa9j@${index}`} span="21">
                                {
                                    showDailyEdit[item.id]?
                                    <div>
                                        <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@r3nc2h@${index}`} className='exchange-row'>
                                            <a href={'javaScript:openhrm(' + item.creater.id + ');'} onClick={e => window.pointerXY(e)} >
                                                <span className='exchange-hrm'>{item.creater.name}:&nbsp;&nbsp;</span>
                                            </a>
                                        </Row>
                                        <Edit ecId={`${this && this.props && this.props.ecId || ''}_Edit@bfcxz9@${index}`}
                                            richid={`${item.id}_daily`}
                                            showRichfun={this.showRichfun}
                                            showDialogfun={this.showDialogfun}
                                            value={item.content}
                                            transfStr={this.transfStr}
                                            showRich={true}
                                            richChange={(text) =>{this.setState({richValue:text});}}
                                            richSubmitfun={(v) =>{this.editDaily(item.id,0);}}
                                            showRichfun={(bool) =>{
                                                let showDailyEdit1 = showDailyEdit;
                                                showDailyEdit1[item.id] = bool;
                                                this.setState({ showDailyEdit: showDailyEdit1 });
                                            }}
                                            exchangeList={_exchangeList}
                                            loading={false}
                                        />
                                    </div>:
                                    <div>
                                        <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@rnv1x4@${index}`} className='exchange-row'>
                                            <a href={'javaScript:openhrm(' + item.creater.id + ');'} onClick={e => window.pointerXY(e)} >
                                                <span className='exchange-hrm'>{item.creater.name}:&nbsp;&nbsp;</span>
                                            </a>
                                            <span dangerouslySetInnerHTML={{ __html: item.content }}></span>
                                        </Row>
                                        <span className='exchange-date'>{item.createdate + ' ' + item.createtime}</span>
                                        <span style={{ float: 'right' }}>
                                            {item.canEdit&&<span className='exchange-operate' onClick={() => {
                                                this.deleteDaily(item.id,0);
                                            }}><a>{getLabel(131966,"删除")}</a>
                                            </span>}
                                            {item.canEdit&&<span className='exchange-operate' onClick={() => this.bianjiHandle(item,0)}><a>{getLabel(126036, "编辑")}</a>
                                            </span>}
                                            <span className='exchange-operate' onClick={() => this.huifuHandle(item)}><a>{getLabel('128123', '回复')}</a>
                                            </span>
                                        </span>
                                    </div>
                                }
                                {
                                    item.replys&&item.replys.map((item,index) =>{
                                        return <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@cug4w3@${index}`} style={{padding:0}}>
                                            <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@t6pmar@${index}`} style={{padding:0}}>
                                                <span className='exchange-hrm'>
                                                    <a href={'javaScript:openhrm('+item.creater.id+');'} onClick={e => window.pointerXY(e)} >
                                                        <span className='exchange-hrm'>{item.creater.name}&nbsp;&nbsp;</span>
                                                    </a>
                                                </span>
                                                <span className='exchange-date'>{item.createdate+' '+item.createtime}</span>
                                            </Row>
                                            <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@yutxbk@${index}`} style={{ padding: 0 }}>
                                                <span dangerouslySetInnerHTML={{ __html: getLabel('128123','回复')+'：' + item.content }}></span>
                                            </Row>
                                        </Row>
                                    })
                                }
                                {showReply[item.id]&&<Row ecId={`${this && this.props && this.props.ecId || ''}_Row@ehqpsk@${index}`} style={{padding:0}}>
                                    <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@xk5owc@${index}`} style={{padding:0}}>
                                    <WeaTextarea ecId={`${this && this.props && this.props.ecId || ''}_WeaTextarea@zgu9oj@${index}`} viewAttr={2} onChange={(v) =>{setReply(v)}} />
                                    </Row>
                                    <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@vlul1o@${index}`} style={{padding:'5px 0'}}>
                                    <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@c53k19@${index}`} key="submit" type="primary" size="small" style={{ display: 'inline-block', borderRadius: '3px', float: 'right' }} onClick={() => {
                                        saveReply(item.id,"all");
                                        let showReply1 = showReply;
                                        showReply1[item.id]=!showReply1[item.id];
                                        this.setState({showReply:showReply1});
                                    }} >{getLabel(383336,"提交")}</Button>
                                    </Row>
                                </Row>}
                            </Col>
                        </Row>
                    )
                } else if (type == 2) {
                    let BrowserList = toJS(_BrowserList);
                    const sortid = prjid;
                    let wf_auth_url = _exchangeList ? _exchangeList.wf_auth_url : "";
                    let doc_auth_url = _exchangeList ? _exchangeList.doc_auth_url : "";
                    let acc_auth_url = _exchangeList ? _exchangeList.acc_auth_url : "";

                    let browserParam = {
                        hasAddBtn: false,
                        hasAdvanceSerach: true,
                        idSeparator: ",",
                        isAutoComplete: 1,
                        isDetail: 0,
                        isMultCheckbox: false,
                        isSingle: true,
                        linkUrl: "/hrm/resource/HrmResource.jsp?id=",
                        pageSize: 10,
                        quickSearchName: "",
                        title: getLabel(383424,"人力资源"),
                        type: "1",
                        viewAttr: 1,
                    }
                    Array.isArray(BrowserList.datas) && BrowserList.datas.map((element, index) => {
                        if (element.id == item.id) {
                            let replaceDatas = [];
                            replaceDatas.push(element.creater);
                            element['id'] == BrowserList[element['id']];
                            let showDom = element.isEdit == true ?
                                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@bciwch@${index}`}>
                                    <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@hv6h2k@${index}`} height='252px'>
                                        <div style={{ backgroundColor: '#ffffff', height: '242px', marginBottom: '10px' }}>
                                            <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@7x6117@${index}`}>
                                                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@jhk0is`} span={3}>
                                                    <img className="manager-img" src={`${element.creater.imgurl}`} style={{ borderRadius: '20px' }} />
                                                </Col>
                                                <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@5wrvs9`} span={21}>
                                                    <div className="jiaoliu-box">
                                                        <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@h23w9z`} {...browserParam} replaceDatas={replaceDatas} style={{ display: 'inline-block' }} />
                                                    </div>
                                                </Col>
                                            </Row>
                                            <Edit ecId={`${this && this.props && this.props.ecId || ''}_Edit@p1asze@${index}`}
                                                richid={`${element.id}_discuss`}
                                                showRichfun={this.showRichfun}
                                                showDialogfun={this.showDialogfun}
                                                value={BrowserList[element.id].remark}
                                                transfStr={this.transfStr}
                                                showRich={true}
                                                richChange={(text) =>{this.onChange(element.id, text);this.setState({richValue:text});}}
                                                richSubmitfun={(v) =>{this.dosubmit(element.id)}}
                                                showRichfun={(bool) =>{this.docancel(index,bool)}}
                                                exchangeList={_exchangeList}
                                                loading={false}
                                            />
                                        </div>
                                    </WeaNewScroll>
                                </Row>
                                : <div style={{ borderBottom: '1px solid #E2E2E2', backgroundColor: '#ffffff',marginTop:'20px' }}>
                                    <JlChild ecId={`${this && this.props && this.props.ecId || ''}_JlChild@vai46t@${index}`} element={element} replaceDatas={replaceDatas} sortid={sortid} wf_auth_url={wf_auth_url} doc_auth_url={doc_auth_url} acc_auth_url={acc_auth_url} />
                                    <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@yntbeo@${index}`}>
                                        <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@ccdb3g@${index}`} span={3}></Col>
                                        <span style={{ color: '#999999' }}>
                                            {element.time}
                                        </span>
                                        {
                                            element.canedit ? (
                                                <span
                                                    className="wea-mbwcbr-item icon-coms-edit"
                                                    style={{ cursor: 'pointer', position: 'absolute', right: '70px', color: '#b2b2b2' }}
                                                    onClick={() => {
                                                        this.edit(element.id);
                                                        this.setState({richValue:BrowserList[element.id].remark});
                                                        this.setState({richMethod:(v) =>{this.dosubmit(element.id)}});
                                                        this.setState({richValueChangeMethod:(text) =>{this.onChange(element.id, text);this.setState({richValue:text})}});
                                                        this.setState({isCreate:false});
                                                    }}
                                                ><span style={{ fontSize: "12px", color: '#666666' }}>&nbsp;{`${getLabel(126036, "编辑")}`}</span></span>
                                            ) : ""
                                        }
                                        {
                                            element.canedit ? (
                                                <span
                                                    className="wea-mbwcbr-item icon-coms-delete"
                                                    onClick={() => this.delete(element.id)}
                                                    style={{ position: 'absolute', right: '10px', cursor: 'pointer', color: '#b2b2b2' }}
                                                ><span style={{ fontSize: "12px", color: '#666666' }}>&nbsp;{`${getLabel(131966, "删除")}`}</span></span>
                                            ) : ""
                                        }
                                    </Row>
                                </div>
                            datas.push(showDom);
                        }
                    })
                } else if (type == 3) {
                    datas.push(<Log ecId={`${this && this.props && this.props.ecId || ''}_Log@beb5kp@${index}`} {...item} />);
                }
            })
        } else if (selectedDynamicTab == 1) {
            dailys && dailys.map((item, index) => {
                datas.push(
                    <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@mau6uq@${index}`} style={{ borderBottom: '1px solid #E2E2E2', marginTop: '20px' }}>
                        <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@duk0rm@${index}`} span="3">
                            <img src={item.creater.imgurl} className="manager-img" style={{ marginLeft: "0px" }} />
                        </Col>
                        <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@yuskfc@${index}`} span="21">
                            {
                                showDailyEdit[item.id]?
                                <div>
                                    <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@tt3mr3@${index}`} className='exchange-row'>
                                        <a href={'javaScript:openhrm(' + item.creater.id + ');'} onClick={e => window.pointerXY(e)} >
                                            <span className='exchange-hrm'>{item.creater.name}:&nbsp;&nbsp;</span>
                                        </a>
                                    </Row>
                                    <Edit ecId={`${this && this.props && this.props.ecId || ''}_Edit@dxrirm@${index}`}
                                        richid={`${item.id}_daily`}
                                        showRichfun={this.showRichfun}
                                        showDialogfun={this.showDialogfun}
                                        value={item.content}
                                        transfStr={this.transfStr}
                                        showRich={true}
                                        richChange={(text) =>{this.setState({richValue:text});}}
                                        richSubmitfun={(v) =>{this.editDaily(item.id,1);}}
                                        showRichfun={(bool) =>{
                                            let showDailyEdit1 = showDailyEdit;
                                            showDailyEdit1[item.id] = bool;
                                            this.setState({ showDailyEdit: showDailyEdit1 });
                                        }}
                                        exchangeList={_exchangeList}
                                        loading={false}
                                    />
                                </div>:
                                <div>
                                    <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@agfnwo@${index}`} className='exchange-row'>
                                        <a href={'javaScript:openhrm(' + item.creater.id + ');'} onClick={e => window.pointerXY(e)} >
                                            <span className='exchange-hrm'>{item.creater.name}:&nbsp;&nbsp;</span>
                                        </a>
                                        <span dangerouslySetInnerHTML={{ __html: item.content }}></span>
                                    </Row>
                                    <span className='exchange-date'>{item.createdate + ' ' + item.createtime}</span>
                                    <span style={{ float: 'right' }}>
                                        {item.canEdit&&<span className='exchange-operate' onClick={() => {
                                            this.deleteDaily(item.id,1);
                                        }}><a>{getLabel(131966,"删除")}</a>
                                        </span>}
                                        {item.canEdit&&<span className='exchange-operate' onClick={() => this.bianjiHandle(item,1)}><a>{getLabel(126036, "编辑")}</a>
                                        </span>}
                                        <span className='exchange-operate' onClick={() => this.huifuHandle(item)}><a>{getLabel('128123', '回复')}</a>
                                        </span>
                                    </span>
                                </div>
                            }
                            {
                                item.replys&&item.replys.map((item,index) =>{
                                    return <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@5udlcs@${index}`} style={{padding:0}}>
                                        <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@mpvsg9@${index}`} style={{padding:0}}>
                                            <span className='exchange-hrm'>
                                                <a href={'javaScript:openhrm('+item.creater.id+');'} onClick={e => window.pointerXY(e)} >
                                                    <span className='exchange-hrm'>{item.creater.name}&nbsp;&nbsp;</span>
                                                </a>
                                            </span>
                                            <span className='exchange-date'>{item.createdate+' '+item.createtime}</span>
                                        </Row>
                                        <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@mdu1xj@${index}`} style={{ padding: 0 }}>
                                            <span dangerouslySetInnerHTML={{ __html: getLabel('128123','回复')+'：' + item.content }}></span>
                                        </Row>
                                    </Row>
                                })
                            }
                            {showReply[item.id]&&<Row ecId={`${this && this.props && this.props.ecId || ''}_Row@d0alaw@${index}`} style={{padding:0}}>
                                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@s2til0@${index}`} style={{padding:0}}>
                                <WeaTextarea ecId={`${this && this.props && this.props.ecId || ''}_WeaTextarea@ognkq9@${index}`} viewAttr={2} onChange={(v) =>{setReply(v)}} />
                                </Row>
                                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@cmgwll@${index}`} style={{padding:'5px 0'}}>
                                <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@iq8rmy@${index}`} key="submit" type="primary" size="small" style={{ display: 'inline-block', borderRadius: '3px', float: 'right' }} onClick={() => {
                                    saveReply(item.id,"daily");
                                    let showReply1 = showReply;
                                    showReply1[item.id]=!showReply1[item.id];
                                    this.setState({showReply:showReply1});
                                }} >{getLabel(383336,"提交")}</Button>
                                </Row>
                            </Row>}
                        </Col>
                    </Row>
                )
            })
        }else if(selectedDynamicTab==2){
            let BrowserList = toJS(_BrowserList);
            const sortid = prjid;
            let exchangeListDatas = _exchangeList ? _exchangeList.datas : [];
            let wf_auth_url = _exchangeList ? _exchangeList.wf_auth_url : "";
            let doc_auth_url = _exchangeList ? _exchangeList.doc_auth_url : "";
            let acc_auth_url = _exchangeList ? _exchangeList.acc_auth_url : "";

            //相关附件--relateddoc
            let browserParam = {
                hasAddBtn: false,
                hasAdvanceSerach: true,
                idSeparator: ",",
                isAutoComplete: 1,
                isDetail: 0,
                isMultCheckbox: false,
                isSingle: true,
                linkUrl: "/hrm/resource/HrmResource.jsp?id=",
                pageSize: 10,
                quickSearchName: "",
                title: getLabel(383424,"人力资源"),
                type: "1",
                viewAttr: 1,
            }
            Array.isArray(BrowserList.datas) && BrowserList.datas.map((element, index) => {
                if (index != 0) {
                let replaceDatas = [];
                replaceDatas.push(element.creater);
                element['id'] == BrowserList[element['id']]

                let showDom = element.isEdit == true ?
                    <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@d6aj8y@${index}`}>
                        <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@jcu3ch@${index}`} height='252px'>
                            <div style={{ backgroundColor: '#ffffff', height: '242px', marginBottom: '10px' }}>
                                <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@hpomos@${index}`}>
                                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@e5udym`} span={3}>
                                        <img className="manager-img" src={`${element.creater.imgurl}`} style={{ borderRadius: '20px' }} />
                                    </Col>
                                    <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@ym7c8v`} span={21}>
                                        <div className="jiaoliu-box">
                                            <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@78q9lg`} {...browserParam} replaceDatas={replaceDatas} style={{ display: 'inline-block' }} />
                                        </div>
                                    </Col>
                                </Row>
                                <Edit ecId={`${this && this.props && this.props.ecId || ''}_Edit@dgxlww@${index}`}
                                    richid={`${element.id}_discuss`}
                                    showRichfun={this.showRichfun}
                                    showDialogfun={this.showDialogfun}
                                    value={BrowserList[element.id].remark}
                                    transfStr={this.transfStr}
                                    showRich={true}
                                    richChange={(text) =>{this.onChange(element.id, text);this.setState({richValue:text});}}
                                    richSubmitfun={(v) =>{this.dosubmit(element.id)}}
                                    showRichfun={(bool) =>{this.docancel(index,bool)}}
                                    exchangeList={_exchangeList}
                                    loading={false}
                                />
                            </div>
                        </WeaNewScroll>
                    </Row>
                    : <div style={{ borderBottom: '1px solid #E2E2E2', backgroundColor: '#ffffff', marginTop: '20px' }}>
                        <JlChild ecId={`${this && this.props && this.props.ecId || ''}_JlChild@52qd3z@${index}`} element={element} replaceDatas={replaceDatas} sortid={sortid} wf_auth_url={wf_auth_url} doc_auth_url={doc_auth_url} acc_auth_url={acc_auth_url} />
                        <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@sp291v@${index}`}>
                            <Col ecId={`${this && this.props && this.props.ecId || ''}_Col@k36aal@${index}`} span={3}></Col>
                            <span style={{ color: '#999999' }}>
                                {element.time}
                            </span>
                            {
                                element.canedit ? (
                                    <span
                                        className="wea-mbwcbr-item icon-coms-edit"
                                        style={{ cursor: 'pointer', position: 'absolute', right: '70px', color: '#b2b2b2' }}
                                        onClick={() => {
                                            this.edit(element.id);
                                            this.setState({richValue:BrowserList[element.id].remark});
                                            this.setState({richMethod:(v) =>{this.dosubmit(element.id)}});
                                            this.setState({richValueChangeMethod:(text) =>{this.onChange(element.id, text);this.setState({richValue:text})}});
                                            this.setState({isCreate:false});
                                        }}
                                    ><span style={{ fontSize: "12px", color: '#666666' }}>&nbsp;{`${getLabel(126036, "编辑")}`}</span></span>
                                ) : ""
                            }
                            {
                                element.canedit ? (
                                    <span
                                        className="wea-mbwcbr-item icon-coms-delete"
                                        onClick={() => this.delete(element.id)}
                                        style={{ position: 'absolute', right: '10px', cursor: 'pointer', color: '#b2b2b2' }}
                                    ><span style={{ fontSize: "12px", color: '#666666' }}>&nbsp;{`${getLabel(131966, "删除")}`}</span></span>
                                ) : ""
                            }
                        </Row>
                    </div>
                    datas.push(showDom);
                }
            })
            exchangeListDatas && exchangeListDatas.length == 1 && datas.push(<div style={{ textAlign: 'center', height: '85px' }}>
                <span className="icon-blog-Unhappy" style={{ display: 'inline-block', marginTop: '30px' }}><span style={{ paddingLeft: '5px' }}>{getLabel(383567, "暂无相关交流")}</span></span>
            </div>)
        } else if (selectedDynamicTab == 3) {
            logList && logList.map((item, index) => {
                datas.push(<Log ecId={`${this && this.props && this.props.ecId || ''}_Log@ijqehw@${index}`} {...item} />);
            })
        }
        return datas;
    }

    richChange = (text) => {
        const { projectCardStore: { setDaily } } = this.props;
        const { selectedDynamicTab, isCreate, richValueChangeMethod } = this.state;
        if(isCreate){
            this.setState({richValue:text});
            if(selectedDynamicTab == 1){
                setDaily(text);
            }else if(selectedDynamicTab == 2){
                this.onChange('create', text);
            }
        }else{
            richValueChangeMethod(text);
        }
    }

    showRichfun = (bool) => {
        this.setState({ showRich: bool })
    }

    dosubmit = (id) => {
        const {exchangeSave,_BrowserList,setBrowserList,prjid} = this.props.projectCardStore;
		let BrowserList = toJS(_BrowserList);
		let oldBrowserList = { ...BrowserList }
		const sortid = prjid;
		let params = oldBrowserList[id];
		let mewParams = { ...params }
		let canSubmit = false;
		for (let key in mewParams) {
			if (key != 'id' && key != 'sortid') {
				if (key == 'remark') {
					if (mewParams[key]) {
						canSubmit = true
					}
				}
			}
		}

		if (params.docids.length == 0) {
			delete mewParams.docids
		}
		if (params.projectids.length == 0) {
			delete mewParams.projectids
		}
		if (params.relatedcus.length == 0) {
			delete mewParams.relatedcus
		}
		if (params.relateddoc.length == 0) {
			delete mewParams.relateddoc
		}
		if (params.relatedprj.length == 0) {
			delete mewParams.relatedprj
		}
		if (params.relatedwf.length == 0) {
			delete mewParams.relatedwf
		}
		if (params.docids.length > 0) {
			let docidsarr = []
			params.docids.forEach((_e, _index) => {
				docidsarr.push(_e['id']);
			})
			mewParams.docids = docidsarr.join(',');
		}
		if (params.projectids.length > 0) {
			let projectidssarr = []
			params.projectids.forEach((_e, _index) => {
				projectidssarr.push(_e['id']);
			})
			mewParams.projectids = projectidssarr.join(',');

		}
		if (params.relatedcus.length > 0) {//客户和任务有问题
			let relatedcusarr = []
			params.relatedcus.forEach((_e, _index) => {
				relatedcusarr.push(_e['id']);
			})
			mewParams.relatedcus = relatedcusarr.join(',');

		}
		if (params.relateddoc.length > 0) {
			let relateddocarr = []
			params.relateddoc.forEach((_e, _index) => {
				relateddocarr.push(_e['id']);
			})
			mewParams.relateddoc = relateddocarr.join(',');

		}
		if (params.relatedprj.length > 0) {
			let relatedprjarr = []
			params.relatedprj.forEach((_e, _index) => {
				relatedprjarr.push(_e['id']);
			})
			mewParams.relatedprj = relatedprjarr.join(',');

		}
		if (params.relatedwf.length > 0) {
			let relatedwfarr = []
			params.relatedwf.forEach((_e, _index) => {
				relatedwfarr.push(_e['id']);
			})
			mewParams.relatedwf = relatedwfarr.join(',');

		}
		mewParams['id'] = id == 'create' ? '' : id;
		mewParams['sortid'] = sortid;
		let stateBrowserList = { ...BrowserList };
		stateBrowserList['create']['docids'] = []
		stateBrowserList['create']['projectids'] = []
		stateBrowserList['create']['relatedcus'] = []
		stateBrowserList['create']['relateddoc'] = []
		stateBrowserList['create']['relatedprj'] = []
		stateBrowserList['create']['relatedwf'] = []
		stateBrowserList['create']['remark'] = ''

		if (canSubmit) {
			setBrowserList(stateBrowserList);
            exchangeSave(mewParams);
            this.setState({showExDiv:false});
		} else {
			message.error(getLabel(126982,"请填写内容"));
		}
	}

	docancel = (e,flag=false) => {
		const {exchangeList,changeDiscussList} = this.props.projectCardStore;
		let _exchangeList = toJS(exchangeList);
		let oldexchangeList = { ..._exchangeList }
		oldexchangeList.datas.forEach((element, index) => {
			if (e == index) {
				element.isEdit = flag;
			}
		})
		changeDiscussList(oldexchangeList)
	}

    transfStr = (name = '', ids = '', list = [], type = '', id = '') => {
		const {_BrowserList,setBrowserList,exchangeList,prjid} = this.props.projectCardStore;
		let BrowserList = toJS(_BrowserList);
		let _exchangeList = toJS(exchangeList);
		let acc_auth_url = _exchangeList ? _exchangeList.acc_auth_url : "";
		let sortid = prjid;
		let str = '';
		let idsArr = [];
		const mirror = {
			37: "doc",
			prjtsk: "task",
			18: "crm",
			152: "workflow",
			135: "project",
			workplan: "workplan",
			blogTemplate: "blogTemplate"
		}
		const browserType = {
			37: "docids",
			prjtsk: "relatedprj",
			18: "relatedcus",
			152: "relatedwf",
			135: "projectids",//项目
			Upload: "relateddoc",//附件
		}
		list.map(item => {
			if (name === 'Browser') {
				let urlstr=this.openProjectAppLink(mirror[type],item.id,sortid);
				str +=`&nbsp;<a  href='${urlstr}' target='new'  linkid='${item.id}' linkType='${mirror[type]}'  unselectable='off' contenteditable='false' style='cursor:pointer;text-decoration:underline !important;margin-right:8px'>${item.name || item.showname}</a>&nbsp;`
				idsArr.push(item.id)
			}
			if (name === 'Upload' && type === 'image') {
				str += '&nbsp;<img class="formImgPlay" src="' + item.imgSrc + '" onclick="ecCom.WeaRichText.playImg(this)" data-imgsrc="' + item.imgSrc + '" />&nbsp;'
			}
			if (name === 'Upload' && type === 'file') {
				str += `&nbsp;<a onclick='openProjectDiscussDoc(this,${ids[0]},${sortid},${acc_auth_url})' unselectable='off' contenteditable='false' style='cursor:pointer;text-decoration:underline !important;margin-right:8px'>${item.filename}</a>&nbsp;`
				if (item.showLoad) {
					let urlstr=item.loadlink+"&sortid="+sortid;
					str += `<a href='${urlstr}' target='_blank'  unselectable='off' contenteditable='false' style='cursor:pointer;text-decoration:underline !important;margin-right:8px'>${getLabel(258,"下载")}(${item.filesize})</a>&nbsp;`
				}
			}
		})

		let oldBrowserList = { ...BrowserList };
		if (oldBrowserList[id] == undefined) {
			oldBrowserList[id] = {};
		}
		if (name != 'Upload') {
			oldBrowserList[id][browserType[type]] = list;
		} else {
			oldBrowserList[id]['relateddoc'].push({ id: ids[0] })

		}
		setBrowserList(oldBrowserList);
		return str
	}

    onChange = (id, text) => {
		const {_BrowserList,setBrowserList} = this.props.projectCardStore;
		let BrowserList = toJS(_BrowserList);
		let oldBrowserList = { ...BrowserList };
		if (oldBrowserList[id] == undefined) {
			oldBrowserList[id] = {};
		}
		oldBrowserList[id]['remark'] = text;
		setBrowserList(oldBrowserList);
    }
    
    edit = (_id) => {
		const {exchangeList,changeDiscussList,_BrowserList,setBrowserList} = this.props.projectCardStore;
		let _exchangeList = toJS(exchangeList);
		let BrowserList = toJS(_BrowserList);
		let oldBrowserList = { ...BrowserList };
		let oldexchangeList = { ..._exchangeList }
		oldexchangeList.datas.forEach((element, index) => {
			if (_id == element['id']) {
				element.isEdit = true;
				if (oldBrowserList[_id] == undefined) {
					oldBrowserList[_id] = {};
				}
				oldBrowserList[_id].relatedwf = element.relatedwf;
				oldBrowserList[_id].docids = element.docids;
				oldBrowserList[_id].projectids = element.projectids;
				oldBrowserList[_id].relatedcus = element.relatedcus;
				oldBrowserList[_id].relateddoc = element.relateddoc;
				oldBrowserList[_id].relatedprj = element.relatedprj;
			}
		})
		setBrowserList(oldBrowserList);
		changeDiscussList(oldexchangeList)
    }
    
    delete = (e) => {
		const {exchangeDelete,prjid} = this.props.projectCardStore;
		const sortid = prjid;
		confirm({
			title : getLabel(131329,"信息确认"),
			content : getLabel(15097,"确定要删除吗？"),
			onOk(){
				exchangeDelete({ id: e, sortid: sortid });
			},
			onCancel() {}
	        })
    }

    deleteDaily = (e,type) => {
		const {deleteDaily,prjid} = this.props.projectCardStore;
		confirm({
			title : getLabel(131329,"信息确认"),
			content : getLabel(15097,"确定要删除吗？"),
			onOk(){
				deleteDaily({ id: e, prjid: prjid },type);
			},
			onCancel() {}
	        })
    }

    changeDynamicTab = (index) =>{
        const {getPortalProjectDynamicInfo,getDailys,getExchangeList,setExchangeList,setBrowserList} = this.props.projectCardStore;
        if(index==0){
            getPortalProjectDynamicInfo("all");
        }else if(index==1){
            getDailys();
        }else if(index==2){
            setExchangeList({});
            setBrowserList({});
            getExchangeList();
        }else if(index==3){
            getPortalProjectDynamicInfo("log");
        }
        this.setState({ selectedDynamicTab: index, showDailyDiv: false, showExDiv: false, showReply: {}, showRich: false });
    }

    openProjectAppLink=(linkType, linkid, prjid)=>{
		const {exchangeList} = this.props.projectCardStore;
		let _exchangeList = toJS(exchangeList);
		let wf_auth_url = _exchangeList ? _exchangeList.wf_auth_url : "";
		let doc_auth_url = _exchangeList ? _exchangeList.doc_auth_url : "";
		let acc_auth_url = _exchangeList ? _exchangeList.acc_auth_url : "";
        if (linkType == "doc")
            return `/spa/document/index.jsp?id=${linkid}&prjid=${prjid}`+doc_auth_url;
        else if (linkType == "task")
            return `/spa/prj/index.html#/main/prj/taskCard?taskid=${linkid}`;
        else if (linkType == "crm")
            return `/spa/crm/static/index.html#/main/crm/customerView?customerId=${linkid}`;
        else if (linkType == "workflow")
            return `/spa/workflow/static4form/index.html#/main/workflow/req?fromModul=prj&modulResourceId=${prjid}&requestid=${linkid}`+wf_auth_url;
        else if (linkType == "project")
            return `/spa/prj/index.html#/main/prj/projectCard?prjid=${prjid}`;
        else
            return '';
    }

    getRichSubmitfun = (v) =>{
        const { projectCardStore: { submitDaily } } = this.props;
        const { selectedDynamicTab, isCreate, richMethod } = this.state;
        if(isCreate){
            if(selectedDynamicTab == 1){
                submitDaily(v);
            }else if(selectedDynamicTab == 2){
                this.dosubmit(v);
            }
        }else{
            richMethod();
        }
    }

    editDaily = (id,tabKey) =>{
        const { projectCardStore: { editDaily } } = this.props;
        const { richValue } = this.state;
        editDaily(id,richValue,tabKey);
    }

    getRightMenu() {
        const { projectCardStore } = this.props;
        const { rightMenu, isApprove, prjCardStore, topTab } = projectCardStore;
        const { shareTableStore } = prjCardStore;
        let { selectedRowKeys } = shareTableStore;
        const tabDatas1 = toJS(topTab);
        const key = this.state.selectedKey;
        let btnArr = [];
        rightMenu && rightMenu.length > 0 && rightMenu.map(m => {
            if(m.type !== "BTN_LOG"){
                let disabled = false;

                if (tabDatas1) {
                    for (let i = 0; i < tabDatas1.length; i++) {
                        if (tabDatas1[i].shortname == "stageset" && tabDatas1[i].key == key && prjCardStore.stageInfo.selectedRowKeys.length == 0) {//项目卡片
                            if (m.type == "BTN_COPY" || m.type == "BTN_DELETE") {
                                disabled = true;
                            }
                        }

                        if (tabDatas1[i].shortname == "prjshare" && tabDatas1[i].key == key && selectedRowKeys.length == 0) {//项目卡片
                            if (m.type == "BTN_COPY" || m.type == "BTN_DELETE" || m.type == "BTN_DELETEBATCH") {
                                disabled = true;
                            }
                        }

                        if(tabDatas1[i].shortname  == "prjinfo" && tabDatas1[i].key == key && isApprove){
                            if(m.menuIcon == "icon-coms-Approval"){
                                disabled = true;
                            }
                        }
                    }
                }

                btnArr.push({
                    icon: <i className={m.menuIcon} />,
                    content: m.menuName,
                    disabled: disabled
                })
            }
        });
        return btnArr
    }

    onRightMenuClick(key) {
        const { projectCardStore, fromPortal, dellCallBack = () =>{}, changeCallBack = () =>{} } = this.props;
        const { rightMenu, prjid, projectInfoStore, projectInfo:{prjname}, topTab, prjCardStore } = projectCardStore;
        const { shareTableStore } = prjCardStore;
        let { selectedRowKeys } = shareTableStore;
        const tabDatas1 = toJS(topTab);
        const selectTabKey = this.state.selectedKey;

        let keyNew = 0;
        rightMenu && rightMenu.length > 0 && rightMenu.map((m, i) => {
            if(m.type == "BTN_LOG"){
                keyNew--;
            }
            if (Number(key) == keyNew) {
                for (let i = 0; i < tabDatas1.length; i++) {
                    if (tabDatas1[i].shortname == "prjinfo" && tabDatas1[i].key == selectTabKey) {//项目卡片
                        let fn = m.menuFun.indexOf('this') >= 0 ? `${m.menuFun.split('this')[0]})` : m.menuFun;
                        if (fn != "") {
                            fn = fn.substring(0, fn.indexOf('('));
                            if ('onNormal' == fn) {   //正常
                                projectCardStore.doPlanOpt({ method: 'normal', prjid: prjid, callBack: () => {changeCallBack();} });
                            } else if ('onOver' == fn) {   //延期
                                projectCardStore.doPlanOpt({ method: 'delay', prjid: prjid, callBack: () => {changeCallBack();} });
                            } else if ('onFinish' == fn) {   //完成
                                projectCardStore.doPlanOpt({ method: 'complete', prjid: prjid, callBack: () => {changeCallBack();} });
                            } else if ('onFrozen' == fn) {   //冻结
                                projectCardStore.doPlanOpt({ method: 'freeze', prjid: prjid, callBack: () => {changeCallBack();} });
                            } else if ('onToggleStatus' == fn) {
                                projectCardStore.doPlanOpt({ method: 'togglestatus', prjid: prjid, statusid: m.params, callBack: () => {changeCallBack();} });
                            }
                        } else {
                            if (m.type == "BTN_EDIT") { //编辑
                                projectInfoStore.handleDialog(true,prjid,{viewtype:'edit',prjid:prjid}) ;
                            } else if (m.type == "BTN_SAVE") {  //保存
                                projectCardStore.savePrjInfo({ prjid: prjid });
                            } else if (m.type == "BTN_NEWREQ") {  //新建流程
                                window.open("/spa/workflow/static/index.html#/main/workflow/add?prjid=" + prjid, "_blank");
                            } else if (m.type == "BTN_NEWDOC") {  //新建文档
                                window.open("/spa/document/static/index.html#/main/document/add?moudleFrom=prj&prjid=" + prjid, "_blank");
                            } else if (m.type == "BTN_NEWRQ") {  //新建日程
                                this.setState({ workPlanVisible: true })
                            } else if (m.type == "BTN_NEWMT") {  //新建会议
                                window.open("/spa/meeting/static/index.html#/main/meeting/dialogsingle?type=create&projectid=" + prjid, "_blank");
                            } else if (m.type == "BTN_SAVETEMPLET") {  //另存为模板
                                projectInfoStore.prjid = prjid;
                                projectInfoStore.prjname = prjname;
                                projectInfoStore.setVisiable(true);
                            } else if (m.type == "BTN_DELETE") {
                                projectInfoStore.delPrjInfo({ method: "del", prjid: prjid, from: "portal", callBack: fromPortal?() => {dellCallBack();}:() =>{this.context.router.push({pathname: "/main/prj/portal"});} });
                            } 
                        }
                    }else if (tabDatas1[i].shortname == "prjshare" && tabDatas1[i].key == selectTabKey) {//共享设置
                        if (m.type == "BTN_APPEND") {  //添加
                            prjCardStore.showAddShareModal(true);
                        } else if (m.type == 'BTN_DELETEBATCH') { //批量删除
                            prjCardStore.delBatchShare(`${toJS(selectedRowKeys)}`);
                        }
                    }
                }
                
            }
            keyNew++;
        });
    }

    getButtons() {
        const { prefixCls, projectCardStore, fromPortal, dellCallBack = () =>{} } = this.props;
        const { rightMenu, prjid, statistics: { rwzs }, baseInfo:{members}, projectInfoStore, topTab, prjCardStore } = projectCardStore;
        const { shareTableStore } = prjCardStore;
        let { selectedRowKeys } = shareTableStore;
        let btnArr = [];
        const tabDatas1 = toJS(topTab);
        const key = this.state.selectedKey;
        if (tabDatas1) {
            for (let i = 0; i < tabDatas1.length; i++) {
                if (tabDatas1[i].shortname == "prjinfo" && tabDatas1[i].key == key) {//项目卡片
                    btnArr.push(
                        <span className={`${prefixCls}-statistic-block`}>
                            <span>{getLabel('382623','任务数')}：{rwzs}</span>
                            <span>{getLabel('518260','成员数')}：{members}</span>
                        </span>
                    );
                }
            }
        }
        rightMenu && rightMenu.length > 0 && rightMenu.map(m => {
            let disabled = false;
            if (tabDatas1) {
                for (let i = 0; i < tabDatas1.length; i++) {
                    if (tabDatas1[i].shortname == "prjshare" && tabDatas1[i].key == key && selectedRowKeys.length == 0) {//项目卡片
                        if (m.type == "BTN_COPY" || m.type == "BTN_DELETE" || m.type == "BTN_DELETEBATCH") {
                            disabled = true;
                        }
                    }
                }
            }
            m.isTop == '1' && btnArr.length < 4 && btnArr.push(
                <Button ecId={`${this && this.props && this.props.ecId || ''}_Button@sqnwo3@${m.type}`} type="primary"
                    disabled={disabled}
                    onClick={() => {
                        for (let i = 0; i < tabDatas1.length; i++) {
                            if (tabDatas1[i].shortname == "prjinfo" && tabDatas1[i].key == key) {//项目卡片
                                if (m.type == "BTN_EDIT") { //编辑
                                    projectInfoStore.handleDialog(true,prjid,{viewtype:'edit',prjid:prjid}) ;
                                } else if (m.type == "BTN_DELETE") {  //删除
                                    projectInfoStore.delPrjInfo({ method: "del", prjid: prjid, from: "portal", callBack: fromPortal?() => {dellCallBack();}:() =>{this.context.router.push({pathname: "/main/prj/portal"});} });
                                }
                            }else if (tabDatas1[i].shortname == "prjshare" && tabDatas1[i].key == key) {//共享设置
                                if (m.type == "BTN_APPEND") {  //添加
                                    prjCardStore.showAddShareModal(true);
                                } else if (m.type == 'BTN_DELETEBATCH') { //批量删除
                                    prjCardStore.delBatchShare(`${toJS(selectedRowKeys)}`);
                                }
                            }
                        }
                    }}
                >
                    {m.menuName}
                </Button>
            );
        });
        return btnArr;
    }

    changeTab = (v) =>{
        const { projectCardStore } = this.props;
        const { topTab, getRightMenu, prjCardStore, prjid } = projectCardStore;
        const tabDatas1 = toJS(topTab);
        const key = v;
        this.setState({ selectedKey: v });
        if (tabDatas1) {
            for (let i = 0; i < tabDatas1.length; i++) {
                if(tabDatas1[i].shortname == "prjinfo" && tabDatas1[i].key == key){
                    this.setState({ selectedDynamicTab: '0' });
                    projectCardStore.setPrjid(prjid);
                    prjCardStore.getPrjTabs({prjid : prjid});
                }else if (tabDatas1[i].shortname == "prjshare" && tabDatas1[i].key == key) {//项目卡片
                    prjCardStore.prjid = prjid;
                    prjCardStore.getPrjShareList();
                    getRightMenu({'type':'prjshare'});
                }else if(tabDatas1[i].shortname == "tasklist" && tabDatas1[i].key == key){
                    getRightMenu({'type':'taskview'});
                }
            }
        }
    }

    setWorkPlanVisible = (bool) => {
        this.setState({ workPlanVisible: bool })
    }

    forwardProjectCard(v){
        const path = "/portal/card?prjid="+v;
        this.context.router.push({
            pathname: "/main/prj"+path
        });
        const { selectedKey } = this.state;
        const { projectCardStore } = this.props;
        const { topTab, getRightMenu, prjCardStore, setPrjidFun } = projectCardStore;
        setPrjidFun(v);
        prjCardStore.getPrjTabs({prjid : v});
        const tabDatas1 = toJS(topTab);
        if (tabDatas1) {
            for (let i = 0; i < tabDatas1.length; i++) {
                if (tabDatas1[i].shortname == "prjshare" && tabDatas1[i].key == selectedKey) {//项目卡片
                    getRightMenu({'type':'prjshare'});
                    prjCardStore.prjid = v;
                    prjCardStore.getPrjShareList();
                }
            }
        }
    }

    dellCallBack = () =>{
        const { projectCardStore:{projectInfoStore}, dellCallBack, fromPortal } = this.props;
        fromPortal?dellCallBack():this.context.router.push({pathname: "/main/prj/portal"});
        projectInfoStore.handleDialog(false);
    }

}

export default ProjectCard;